package com.examples.constant;

import com.google.inject.Guice;
import com.google.inject.Inject;
import com.google.inject.name.Named;
import com.google.inject.name.Names;
import lombok.Getter;
import lombok.val;

/**
 * 绑定常量
 */
public class ConstantInjectDemo {
    @Inject
    @Named("value")
    @Getter
    private int n;
    public static void main(String[] args) {

        val c = Guice.createInjector(binder -> binder.bindConstant().annotatedWith(Names.named("value")).to(12))
                .getInstance(ConstantInjectDemo.class);
        System.out.println(c.getN());

    }
}
